<%@ page import="com.informet.ipd.modelo.dao.MActividadDao" %>
<%@ page import="com.informet.ipd.modelo.vo.MActividadVO" %>
<%@ page import="com.informet.ipd.struts.form.MActividadForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>
<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/tags/c" prefix="c"%>

<%

            StringBuffer cadenaSalida = new StringBuffer();
            List lista = null;


            MActividadDao supportFacade = new MActividadDao();
            MActividadForm form1 = new MActividadForm();
            MActividadVO mAPer = null;
            MActividadVO mAPerm = null;
            try {
                String um = request.getParameter("um");
                String tipoAct = request.getParameter("tipoUm");
                int codActPer = Integer.parseInt(request.getParameter("codActPer"));

                //int codActPerm = Integer.parseInt(request.getParameter("codActPerm"));
                //double cant = Double.parseDouble(request.getParameter("cant"));
                int cant = Integer.parseInt(request.getParameter("cant"));
                int cod = Integer.parseInt(request.getParameter("codigo"));
                int tipo = Integer.parseInt(request.getParameter("tipo"));
                int idMetaAPer = Integer.parseInt(request.getParameter("idMetaAPer"));

                mAPer = new MActividadVO(um, cant, tipoAct, cod, codActPer,idMetaAPer,0);
                supportFacade.spMan(tipo, mAPer);
                //int max=supportFacade.maximo();
                //mAPerm = new MActividadVO(um, cant, tipoAct, max, codActPer,codActPerm);
                //supportFacade.spManM(tipo, mAPerm);
                lista = supportFacade.getListById(codActPer);
                form1.setListaMAPermanente(lista);
                cadenaSalida.append("<table id='tabla1' width='99%' align='right' class='userTable'>");
                cadenaSalida.append("<tr class='even' align='center'>");
                cadenaSalida.append("<th class='textoTR'>#</th>");
                cadenaSalida.append("<th class='textoTR'>Descripci&oacute;n </th> ");
                 cadenaSalida.append("<th class='textoTR'>Cantidad</th> ");
                 cadenaSalida.append("<th class='textoTR'>UM</th> ");
                cadenaSalida.append("<th class='textoTR'>Editar</th>");
                cadenaSalida.append("<th class='textoTR'>Eliminar</th> ");
                cadenaSalida.append("</tr>");
                int i=1;
                Iterator it = lista.iterator();
                while (it.hasNext()) {
                    mAPer = (MActividadVO) it.next();

                    cadenaSalida.append("<tr align='center'> ");
                    cadenaSalida.append("<td width='10%' align='center'>" + mAPer.getNUM_IDOBJ() + "." +mAPer.getNUM_IDOBJESP()+ "."+mAPer.getNUM_IDACTPER()+ "."+mAPer.getNUM_IDMACTPER()+ "." + "</td>");
                    cadenaSalida.append("<td style='width:1500px;text-align: left' align='center'>" + mAPer.getTX_UMACTPER() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + mAPer.getNUM_CANTACTPER() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + mAPer.getTX_TIPOACTPER() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editar('" + mAPer.getNUM_CODMETAAPER_PK() + "','" + mAPer.getNUM_IDMACTPER()+ "','" + mAPer.getTX_UMACTPER() + "','" + mAPer.getNUM_CANTACTPER() + "','" +  mAPer.getTX_TIPOACTPER().trim() + "');posicioninicial();\" >");

                    cadenaSalida.append("</td>");
                    cadenaSalida.append("<td width='10%' align='center'> ");
                    cadenaSalida.append("<img style='cursor:pointer' title='Eliminar' alt='Eliminar' border=0  src='images/b_drop.png' oncler=0  src='images/b_dropick=\"eliminar('" + mAPer.getNUM_CODMETAAPER_PK() + "');\" >");
                    cadenaSalida.append("</td>");

                    cadenaSalida.append("</tr>");
                }
            } catch (Exception e) {
                    cadenaSalida.append("error : "+e.toString());
            }
            out.print(cadenaSalida);
%>